package com.zjsru.oneDay;

public class reversePrefix {
    public String reversePrefix(String word, char ch) {
        char[] cs = word.toCharArray();
        int n = cs.length,idx = -1;
        for (int i = 0; i < n && idx == -1; i++) {
            if(cs[i] == ch){
                idx = i;
            }
        }
        int l = 0,r =idx;
        while(l < r){
            char c =cs[1];
            cs[l++] = cs[r];
            cs[r--] =c;
        }
        return String.valueOf(cs);
    }
    public static void main(String[] args){
        reversePrefix reversePrefix = new reversePrefix();
        String word = "abcdefd";
        char ch = 'd';
        System.out.println(reversePrefix.reversePrefix(word,ch));
    }
}
